<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/swiper.min.css">
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/mui.css?v=1">
		<link rel="stylesheet" type="text/css" href="__API__/lib/css/mobileSelect.css" />
		<link rel="stylesheet" href="__API__/lib/css/style.css">
		<script type="text/javascript" src="__API__/lib/js/jquery-1.11.0.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/mui.js"></script>
		<script src="__API__/lib/js/mobileSelect.js" type="text/javascript" charset="utf-8"></script>
		<script src="__API__/lib/js/city.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="__API__/lib/js/swiper.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/vue.min.js"></script>
		<script type="text/javascript" src="__API__/lib/js/common.js"></script>
		<script type="text/javascript" src="__API__/lib/js/index.js"></script>
	<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script></head>

	<body>
		<div class="register" id="app">
			<div class="registerinfo">
				<div class="registerinfo_con">
					<div class="logo"><img :src="logoImg" alt=""></div>
					<div style="width: 100%; text-align: center; color: #ccc">{{invite_code}}</div>
					<ul class="form_list">
						<li>
							<div class="icon"><img src="__API__/lib/images/l_icon1.png" alt=""></div><input type="tel"  v-model="username" placeholder="请输入手机号" />
						</li>
						<li>
							<div class="icon"><img src="__API__/lib/images/l_icon2.png" alt=""></div>
							<input type="password" name="" id="" v-model="password" placeholder="请输入登录密码" />
						</li>
					</ul>
				</div>
				<div class="register_btn blue_btn" @click="onLogin">
					账号登录
				</div>
				<div class="yzmlogin">
					<span @click="goDetail('register.html')">立即注册</span>
					<span @click="goDetail('quickLogin.html')">快捷登录</span>
				</div>
			</div>
		</div>
		<script>
			var app = null;
			app = new Vue({
				el: '#app',
				data: {
					logoImg:"{:cache('logo')}",
					username: '',
					password: '',
					invite_code:""
				},
				created: function() {
					var that = this;
					var invite_code = "{:input('invite_code')}";
					if(invite_code){
						localStorage.setItem('invite_code',invite_code);

					}
					that.invite_code = localStorage.getItem('invite_code');
					console.log(localStorage.getItem('invite_code'))

				},
				methods: {
					//登录
					onLogin() {
						let that = this;
						console.log('登录')
						let data = {
							mobile: that.username,
							password: that.password
						}
						if(data.mobile == '' || data.password == ''){
							return common.alert('账号或密码不能为空',' ');
						}
						if(!common.validate.isPhone(data.mobile)){
							return common.alert('请输入正确的手机号',' ')
						}
						common.ajax("{:url('Member/login')}",data , function(res){
							common.showToast(res.msg);
							if(res.code == 200){
								localStorage.setItem('member_id',res.data.id);
								localStorage.setItem('openid',res.data.openid);
								localStorage.setItem('token',res.data.token);
								setTimeout(function() {
									common.openUrl("{:url('index')}");
								}, 1000)
							}
						})
					},
					goDetail(url){
						common.openUrl(url);
					}
				}
			})
		</script>
	</body>

</html>
